Yacon.container.Record = function(){
	this.fieldNames    =  new Array();
	this.fieldList     =  new Array();
	this.factvieField  =  null;
	this.parent = null;
};

Yacon.container.Record.Extend(Object,{
	
	/* 添加字段 */
	addField :function(field)
	{
		if (Yacon.isEmpty(field))
			return;
		
		if (Yacon.isEmpty(field.getFieldName()))
			return;
		
		var index = this.fieldNames.indexOf(field.getFieldName().toLowerCase());
	    if (index>-1)
		{
			field.setParent(this);
			this.fieldList[index] = field;
		}else
		{
			field.setParent(this);			 
			this.fieldNames.add(field.getFieldName().toLowerCase());
			this.fieldList.add(field);
		}
	    this.factvieField = field;
	},
	
	/* 获取字段 */
	getField: function(fieldIndex)
	{
		if (Yacon.isEmpty(fieldIndex))
			return this.factvieField;
		else
			this.factvieField = null;
		
		if (Yacon.isNumber(fieldIndex))
		{
			this.factvieField = this.fieldList.get(fieldIndex);
			 
	    }else  if (Yacon.isString(fieldIndex))
	    {
	    	var index = this.fieldNames.indexOf(fieldIndex.toLowerCase());
		    if (index>-1)
			{
		    	this.factvieField = this.fieldList.get(index);
			}
	    }
		return this.factvieField;	
	},
	
	/* 获取字段值 */
	getFieldValue: function(fieldIndex)
	{
		if (this.getField(fieldIndex) == null)
		{
			var fieldValue = "";
			
			return fieldValue;
			
		}else
		{
			return this.factvieField.getFieldValue();
		}
	},
	
	/* 设置字段值 */
	setFieldValue: function(fieldName,fieldValue)
	{
		if (this.getField(fieldName) == null)
			this.creatField(fieldName,fieldValue);
		else
			this.factvieField.setFieldValue(fieldValue);
	},
	
	/* 创建字段 */
	creatField: function(fieldName,fieldValue)
	{
		if (Yacon.isEmpty(fieldName))
			return null;
		
		this.factvieField = new Yacon.container.Field();
		this.factvieField.setFieldName(fieldName);
		this.factvieField.setFieldValue(fieldValue);
		this.addField(this.factvieField);
		return this.factvieField;
	},
	
	/* 释放 */
	free: function()
	{
		this.fieldNames.clear();
		this.fieldList.clear();
	},
	
	/* 获取字段数 */
	getFieldCount: function(){
		return this.fieldNames.length;
	},
	
	getParent : function(){
		return this.parent;
	},
	
	setParent: function(table){
		this.parent = table;
	}
	
	
	
});